<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%
	String baseP = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>重名查询</title>
    <link type="text/css" href="<c:url value='/static/common/css/wechat-common.css'/>" rel="stylesheet"/>
    <style type="text/css">
        .main {
            font-size: 1.6em;
            margin: 8px;
        }
        .main .form {
            height: 50px;
            line-height: 50px;
            border: 1px solid #dddddd;
            width: 100%;
            border-radius: 3px;
        }
        .main .form .label {
            height: 50px;
            line-height: 50px;
            color: #157dfb;
            text-indent: 0.8em;
            float: left;
            width: 70px;
        }
        .main .form .element {
            height: 50px;
            line-height: 50px;
            margin-left: 75px;
            display: block;
        }
        .main .form .element input {
            color: #666;
            font-family: "微软雅黑", serif;
            text-indent: 0.3em;
            border: 0;
            width: 98%;
            font-size: 1.0em;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .main .btn:active {
            background-color: #3300ff;
            cursor: hand;
        }
        #result {
            min-height: 6em;
            margin: 0 10px;
            line-height: 2;
            height: 2em;
            color: #837D7D;
        }
        .main .uptop {
            margin-top: -1.6em;
        }
    </style>
</head>
<body>
<div class="main">
    <div class="form">
        <span class="label">姓名：</span>
        <span class="element"><input id="txt_name" class="no-border" type="text" placeholder="请输入要查询的姓名"/></span>
    </div>
    <div><a class="btn simple no-border" id="btn_query">查 询</a></div>
    <div id="result"></div>
</div>
<script src="<c:url value='/static/theme/police/js/jquery-2.1.1.min.js'/>" type="text/javascript"></script>
<script src="<c:url value='/static/theme/police/js/common.js'/>" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#btn_query").click(function () {
            var name = $("#txt_name").val().trim();
            if (name == null || name == "") {
                toast("请输入要查询的姓名", 1500);
                return;
            }
            $.ajax({
                url: "http://221.224.13.5:8190/econsole/api/query/name",
                type: "post",
                data: {"name": name},
                timeout: 6000,
                beforeSend: function () {
                    loading();
                },
                success: function (data) {
                    if (0 == data.data) {
                        $("#result").html("此姓名人目前没有重名");
                    } else {
                        $("#result").html("此姓名重名人数为" + data.data );
                    }
                    finish();
                },
                error: function () {
                    finish("查询失败")
                }
            });
            event.stopPropagation();
            return false;
        });
    });
    /**
     * 清空结果显示DIV内容
     * */
    function reset() {
        //TODO:清空结果显示DIV内容
//        $("#result div")
    }
    /**
     * 显示Toast消息,
     * @param msg Toast显示内容
     * @duration Toast显示时间[可行，默认显示4s]
     */
    function showToast(msg, duration) {
        var _toast = $("#toast");
        if (_toast.is(":hidden")) {
            _toast.empty().html(msg).addClass("show");
            setTimeout(function () {
                $("#toast").removeClass("show");
            }, duration ? duration : 4000);
        }
    }
</script>
</body>
</html>